package util;

/**
 * Desc: 交通信号灯  枚举类
 * @author: lisha 2018/6/15 17:16
 */
public enum TrafficSign {

    RED("RED","红灯停"),GREEN("GREEN","绿灯行"),YELLOW("YELLOW","等一等");
    private String color;
    private String desc;

    TrafficSign(String color, String desc) {
        this.color = color;
        this.desc = desc;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getDesc(String color){
        for (TrafficSign t : TrafficSign.values()){
            if(color.equals(t.getColor())){
                return t.getDesc();
            }

        }
        return TrafficSign.getDesc("RED");
    }
}
